<template>
    <div id="System_Site">
        <el-card class="box-card">
            <el-form ref="form" :model="form"
                     :label-width="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'100px':'300px'"
                     size="small">
                <el-form-item label="提现金额："
                              :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'">
                    <el-select
                            v-model="form.withdraw_money"
                            multiple
                            filterable
                            allow-create
                            default-first-option
                            placeholder="请选择金额"
                            :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'">
                        <el-option
                                v-for="item in options"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="提现比率：" :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'">
                    <el-input v-model="form.withdraw_rate" :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'"></el-input>
                </el-form-item>
                <el-form-item :label="this.$store.state.name+'说明：'" :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'">
                    <el-select
                            v-model="form.coinesc"
                            multiple
                            filterable
                            allow-create
                            default-first-option
                            :placeholder="'请填写'+this.$store.state.name+'说明'"
                            :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':'minWidth'">
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script>
    export default {
        name: "system_site",
        data() {
            return {
                form: {
                    coinesc: '',
                    withdraw_money: '',
                    withdraw_rate: '',
                },
                options: [{
                    value: '1',
                    label: '1'
                }, {
                    value: '3',
                    label: '3'
                }, {
                    value: '5',
                    label: '5'
                }],
            }
        },
        created() {
            this.getData()
        },
        methods: {
            onSubmit() {
                this.form.withdraw_money = this.form.withdraw_money.join(',');
                this.$axios.post('admin/config/withdraw_set', {config: this.form}).then((res) => {
                    this.$message.success('成功');
                    this.getData();
                });
            },
            getData() {
                this.$axios.post('admin/config/withdraw', '').then((res) => {
                    this.form = res.data;
                    if (this.form.withdraw_money == '') {
                        this.form.withdraw_money = [];
                    } else {
                        this.form.withdraw_money = this.form.withdraw_money.split(",")
                    }
                });
            },
        }
    }
</script>

<style scoped>

</style>